﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using StreamLink.SLDTO;

public partial class frmLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void Login_Onclick(object sender, EventArgs e)
    {


        if ((UserName.Text != "") && (Password.Text != ""))
        {



            string[] Namefield = new string[2];
            string[] Valuefield = new string[2];

            Namefield[0] = "@UserName";
            Namefield[1] = "@Password";

            Valuefield[0] = UserName.Text;
            Valuefield[1] = Password.Text;



            DataTable dtbl = SocialKlee.BusinessLogicLayer.BOLyer.GetDataTable("SocialKlee_Checklogin", Namefield, Valuefield);
            if (dtbl.Rows.Count > 0)
            {
                foreach (DataRow DR in dtbl.Rows)
                {

                    Session["FullName"] = DR["Fullname"].ToString();
                    Session["UserID"] = DR["UserID"].ToString();
                    Session["EmailID"] = DR["EmailID"].ToString();
                    Session["Firstname"] = DR["Firstname"].ToString();
                    Session["Lastname"] = DR["Lastname"].ToString();
                    Session["Username"] = DR["Username"].ToString();

                  //  Session.Timeout = 30;

                    Response.Redirect("Home.aspx");
                }
            }
            else
            {
                lblFailureText.Text = " Invalid Username or Password";
            }
        }
        else
        {
            lblFailureText.Text = " Please enter the UserName and Password";
        }
    }




    public void SignUp_Onclick(object sender, EventArgs e)
    {


        string[] NameField = new string[5];
        string[] ValueField = new string[5];
        NameField[0] = "@EmailID";
        NameField[1] = "@Password";
        NameField[2] = "@Firstname";
        NameField[3] = "@Lastname";
        NameField[4] = "@Username";

        ValueField[0] = EmailAddress.Text;
        ValueField[1] = Password1.Text;
        ValueField[2] = Firstname.Text;
        ValueField[3] = LastName.Text;
        ValueField[4] = UserID.Text;
        DataTable Success = SocialKlee.BusinessLogicLayer.BOLyer.GetDataTable("SocialKlee_UserRegistration", NameField, ValueField);

        if (Success.Rows.Count > 0)
        {
            foreach (DataRow DR in Success.Rows)
            {

                Session["FullName"] = DR["Fullname"].ToString();
                Session["UserID"] = DR["UserID"].ToString();
                Session["EmailID"] = DR["EmailID"].ToString();
                Session["Firstname"] = DR["Firstname"].ToString();
                Session["Lastname"] = DR["Lastname"].ToString();
                Session["Username"] = DR["Username"].ToString();

                //  Session.Timeout = 30;

                Response.Redirect("Home.aspx");
            }
        } Response.Redirect("Home.aspx");
    }
}